#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>

namespace DS190719_Polynomial_calc {
int main();

double f(int n, double a[], double x) {
	int i;
	double p = a[n];
	for (i = n; i > 0; i--)
		p = a[n - 1] + x * p;
	return p;
}

#define MAXN 10
#define MAXK 1e7

int main()
{
	clock_t start, stop;
	int i;
	double duration;
	double a[MAXN] = {};
	for (i = 0; i < MAXN; i++)a[i] = (double)i;
	int n = sizeof(a) / sizeof(a[0]) - 1;
	start = clock();
	for(i=0;i<MAXK;i++)
		f(n, a, 1.1);
	stop = clock();
	printf("res=%f\n", f(n, a, 2));
	duration = ((double)(stop - start)) / CLK_TCK/ MAXK;
	printf("ticks2 = %d\n", (stop - start));
	printf("duration2 = %6.2e\n", duration);
	return 0;
}
}

int main_DS190719_Polynomial_calc() {
	return DS190719_Polynomial_calc::main();
}